package com.hsp.demo_08_object_test;

import com.sun.corba.se.spi.orbutil.threadpool.Work;

public class Demo_05 {
    public static void main(String[] args) {
        /*
        5、设计父类--员工类，子类：工人类、农民类、教师类、科学家类、服务生类。
            1、其中工人、农民、服务生只有基本工资。
            2、教师除基本工资外，还有课酬（元/天）。
            3、科学家除基本工资外，还有年终奖。
            4、编写一个测试类，将各种类型的员工的全年工资打印出来。
         */
        Employee05 w1 = new Worker("一号工人", 2500.0, 11.5);
        System.out.println("全年工资为：" + w1.showYearSalary());

        Teacher05 t1  = new Teacher05("一号老师", 3000, 12);
        t1.setClassMoney(30);
        t1.setDay(200);
        System.out.println(t1.getName() + "的元年工资为：" + t1.showYearSalary());


    }
}

class Teacher05 extends Employee05{
    //课酬
    private double classMoney;
    //天数
    private int day;

    public Teacher05(){}

    public Teacher05(String name, double salary, double workMonth){
        super(name, salary, workMonth);
    }

    @Override
    public double showYearSalary() {
        return super.showYearSalary() + this.classMoney * this.day;
    }

    public double getClassMoney() {
        return classMoney;
    }

    public void setClassMoney(double classMoney) {
        this.classMoney = classMoney;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }
}


/**
 * 子类：工人类
 */
class Worker extends Employee05{
    public Worker() {
    }

    public Worker(String name, double salary, double workMonth){
        super(name, salary, workMonth);
    }
}

/**
 * 父类：员工类
 */
class Employee05{
    //姓名
    private String name;
    //每月基本工资
    private double salary;
    //当年上班月数
    private double workMonth;

    public Employee05(){}

    public Employee05(String name, double salary, double workMonth) {
        this.name = name;
        this.salary = salary;
        this.workMonth = workMonth;
    }

    public double showYearSalary(){
        double yearSalary = this.salary * this.workMonth;
        return yearSalary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getWorkMonth() {
        return workMonth;
    }

    public void setWorkMonth(double workMonth) {
        this.workMonth = workMonth;
    }
}
